package hikari.gui.panels.bullet;

import hikari.gui.guicomponents.ExpandablePanel;
import hikari.hcomponents.physics.PhysicsData;
import hikari.managers.Manager3D;
import org.swig.jirr.ISceneNode;
import org.swig.jirr.IVideoDriver;
import org.swig.jirr.SColor;
import org.swig.jirr.SMaterial;

/**
 * @author sad
 */
public abstract class IBulletRigidBodyEditPanel extends ExpandablePanel {

    protected ISceneNode dummy;
    protected PhysicsData data;

    public void onDrawBeforeGui(ISceneNode node, Manager3D manager) {
        dummy.setPosition(data.getOffsetPosition());
        dummy.setRotation(data.getOffsetRotation());
        IVideoDriver driver = manager.getVideoDriver();
        driver.setTransformationAsInNodeWithoutScale(dummy);
        driver.setMaterial(new SMaterial().setDiffuseColor(SColor.RED));
        drawGizmo(manager);

    }

    public abstract void drawGizmo(Manager3D manager);

    public void onShow(ISceneNode node, Manager3D manager) {
        ISceneNode tDummy = manager.getSceneManager().addEmptySceneNode();
        this.dummy = tDummy;
        dummy.setParent(node);
    }
    
    public void emptyDummy(){
        dummy=null;
    }

    public void onClose(ISceneNode node, Manager3D manager) {
        if(dummy!=null){
            dummy.remove();
        }
    }
}
